<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>admin列表</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
	<script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery-1.4.2.js"></script>
	  </head>
  
  <body>
   <a  href="${pageContext.request.contextPath}/user_exit">退出:admin</a>
   <a href="${pageContext.request.contextPath}/user_addPage">添加</a>
   <br>

<table border="1px" cellspacing="0" cellpadding="0">
   <tr >  <td> 选择 </td> <td>电影名 </td> <td>导演</td>  <td> 信息 </td> <td>总分</td>  <td>编剧</td> <td>加入日期</td>
   <td>电影图片 </td>  <td>热门</td> <td>操作</td>
    </tr>
    <s:iterator value="mList">
     <tr>
      <td><input type="checkbox" name="group" value="${id}"> </td> 
       <td> ${name} </td> 
        <td>${director } </td>
          <td>${info } </td>
            <td>${score } </td>
        <td> ${bianju }</td><td>  ${date} <td><img  src="${imagpath }" style="width: 100px;height:100px"> </td>  <td><s:if test="ishow==1">热门</s:if><s:else>不热门</s:else> </td>  <td><a href="${pageContext.request.contextPath}/movie_delete?mid=${id}" style="text-decoration: none;" onclick=" return check();">删除</a>
        <a href="${pageContext.request.contextPath}/movie_showMovieInfo?mid=${id}" style="text-decoration: none;">查看</a>
         </td>
     </tr>
     </s:iterator>
   <tr style="height: 100px"><td colspan="9" style="text-align: center;"><input type="button" value="批量删除" onclick="deleSeltedRecords();">
   <input type="button" value="全选" onclick="quanxuan();">
   <input type="button" value="反选" onclick="fanxuan();">
   </td></tr>
</table>
<script type="text/javascript">
function quanxuan(){
   $("input[name='group']").each(function(index){
   $(this).attr("checked",true);
   });
}
function fanxuan(){
  $("input[name='group']").each(function(index,e){
       var booleanChecked=$(this).attr('checked');
       $(this).attr("checked",!booleanChecked);
  });
};
  function check(){
  if(confirm("你确定删除吗？")){
    return true;
  }
  else {
   return false;
  }
  }
  function deleSeltedRecords() {
			var chckBox = $("input[name='group']");
			var num = chckBox.length;
			var ids = "";
			for (var index = 0; index < num; index++) {
				if (chckBox[index].checked) {
					ids += chckBox[index].value + ",";
				}
			}
			if (ids != "") {
				if (window.confirm("确定删除所选记录？")) {
					$.ajax({
						type : "post",
						url : '${pageContext.request.contextPath}/movie_deleteAll.action?ids=' + ids, //要自行删除的action  
						dataType : 'json',
						success : function(data) {
							alert("删除成功");
							window.location.href = "${pageContext.request.contextPath}/movie_AllMovieInfo.action" ;
						},
						error : function(data) {
							alert("系统错误，删除失败");
						}
					});
				}
			} else {
				alert("请选择要删除的记录");
			}
		
 } 
</script>

  </body>
</html>
